//
//      Copyright 2011 richard collins
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

// ****************************************************************************************
// Reads the date and time and displays them on the 1602 display.
// http://www.maxim-ic.com/datasheet/index.mvp/id/2685 for chip info.
// ****************************************************************************************

#include "../common/common.h"
#include "../common/display1602.h"
#include "../common/time1302.h"

int main(void)
{
	AllOff();
	Display1602_Open(1);
	Time1302_Open();

	u8 centry,year,month,day,hour,minute,second;

	char buf[16];

	/* loop forever */
	int i = 0;
	while (1)
	{
		i++;
		//Display1602_Clear();

		GetTime(&hour,&minute,&second);
		if( second&1 )
		{
			sprintf(buf,"%02d:%02d:%02d",hour,minute,second);
		}
		else
		{
			sprintf(buf,"%02d %02d %02d",hour,minute,second);
		}

		Display1602_SetXY(0,0);
		Display1602_Print(buf);

		GetDate(&centry,&year,&month,&day);
		sprintf(buf,"%02d/%02d/%d%02d",day,month,centry,year);

		Display1602_SetXY(0,1);
		Display1602_Print(buf);

//		delay_ms (300);
	}
}













